let layer,$;
layui.use(['layer','jquery','table','form'],function () {
    layer=layui.layer,$=layui.jquery;

    //绑定登录按钮的点击事件
    $("#login").click(function () {
        let username=$('#username').val();
        let password=$('#password').val();
        // if(''==username){
        //     layer.msg('登录账号不能为空',function () {});
        //     return false;
        // }
        console.log("username=%s,password=%s",username,password);
        //1.定义固定盐
        let salt="f1g2h3j4";

        //2.将输入的明文密码与固定盐进行混淆
        let temp=salt.charAt(1)+""+salt.charAt(5)+password+salt.charAt(0)+""+salt.charAt(3);
        //进行md5加密
        let pwd1=md5(temp);

        //jquery请求
        $.post('user/userLogin',{
            mobile:username,
            password:pwd1
        },function (rs) {
            console.log(rs);
            if(rs.code==200){
                layer.msg('登录成功',{icon:6},function () {
                    location.href='goods/toGoods';
                });
            }else{
                layer.msg(rs.msg,{icon:5},function () {});
            }
        },'json');
    });
});